package com.aote.expression.paramprocessor;

import java.util.Map;

import com.aote.expression.Param;
import com.aote.serialnumber.IncreaseSerialFactory;
import com.aote.serialnumber.IncreaseSerialNumber;
import com.aote.util.StringHelper;
import com.browsesoft.htmlcomponent.HTMLBasicComponent;
import com.browsesoft.user.User;

/**
 * 编号默认值处理器
 * 
 */
public class SerialNumberProcessor implements ParamProcessor {

	public String process(Param param, Map attribures, User loginUser,
			HTMLBasicComponent component) {
		Map map = param.getParams();
		String serialName = (String) map.get("name");
		serialName = StringHelper.replaceStr(attribures, serialName, "*");
		String serialParam = (String) map.get("length");
		// 创建编号类,得到编号
		String id = (String) attribures.get("id");
//		IncreaseSerialNumber isn = IncreaseSerialFactory.getInstance()
//				.getSerialNumber(serialName);
//		String result = isn.getSerialNumber(serialParam);
		IncreaseSerialNumber isn = IncreaseSerialFactory.getInstance()
		.getSerialNumber(serialName, id);
		String result = isn.getSerialNumber(serialParam);
		isn.updateNum();
		return result;
	}
}
